package com.supermap.dialogs;

import com.supermap.dialogs.advance.CJDialog;

import javax.swing.*;
import java.awt.*;

public class ProcessBarDialog extends CJDialog {
    private JProgressBar progressBar;
    private int min;
    private int max;
    private int orient;

    public ProcessBarDialog(Frame owner, String title, boolean modal) {
        super(owner, title, modal, 260, 66, null);
    }

    public void setOrient(int orient) {
        this.orient = orient;
    }

    public void setValue(int value) {
        if (progressBar != null) {
            progressBar.setValue(value);
            progressBar.setString(value + "%");
        }
    }

    @Override
    protected void initializeArgs(Object[] args) {
        min = 0;
        max = 100;
        orient = JProgressBar.HORIZONTAL;
    }

    @Override
    protected void initializeCore() {
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        super.confirmBtn.setVisible(false);

        progressBar = new JProgressBar();
        progressBar.setMinimum(min);
        progressBar.setMaximum(max);
        progressBar.setOrientation(orient);
        progressBar.setStringPainted(true);
        progressBar.setString("0%");
        add(progressBar, BorderLayout.CENTER);
    }

    @Override
    protected void doConfirmCore() {

    }
}
